<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->

<head>
<meta charset="utf-8">
<title>撮合交易管理</title>
<link href="${request.getContextPath()}/Public/assets/admin/css/css.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/font-awesome/css/font-awesome.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/simple-line-icons/simple-line-icons.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/css/bootstrap.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/uniform/css/uniform.default.css"
	rel="stylesheet" type="text/css">
<link rel="${request.getContextPath()}/Public/stylesheet"
	type="text/css"
	href="assets/global/plugins/jquery-notific8/jquery.notific8.min.css" />
<link
	href="${request.getContextPath()}/Public/assets/global/css/components-rounded.css"
	id="style_components" rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/css/plugins.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/layout.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/themes/default.css"
	rel="stylesheet" type="text/css" id="style_color">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/custom.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker.min.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/global/css/kkpager.css"
	rel="stylesheet" type="text/css">
<link
	href="${request.getContextPath()}/Public/assets/admin/css/common.css"
	rel="stylesheet" type="text/css">
<link rel="shortcut icon"
	href="${request.getContextPath()}/Public/assets/global/plugins/datatables/media/images/favicon.ico">
<link href="${request.getContextPath()}/Public/css/customerDetail.css"
	rel="stylesheet" type="text/css">
<link href="${request.getContextPath()}/Public/css/business.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="${request.getContextPath()}/Public/My97DatePicker/WdatePicker.js"></script>
<script>
	BASE_URL = '${request.getContextPath()}'
</script>
<body class="page-header-top-fixed">
	<!-- END HEADER -->
	<div class="page-header">
		<!--头部开始-->
		<#include "/include/top.html" />
		<!-- 头部信息结束 -->
		<!-- 头部菜单开始 -->
		<#include "/include/top_menu.html" />
		<!-- 头部菜单结束 -->
	</div>

	<!-- BEGIN PAGE CONTAINER -->
	<div class="page-container">
		<div class="page-content">
			<div class="container-fluid">
				<ul class="page-breadcrumb breadcrumb">
					<li><a href="#">首页</a><i class="fa fa-circle"></i></li>
					<li class="active">撮合交易<i class="fa fa-circle"></i>
					</li>
					<li class="active">撮合交易管理</li>
				</ul>
				<div class="row margin-top-10">
					<div class="col-md-12">
						<!-- <div id="u351" class="text">
							<div class="row margin-top-10">
								<#if Session['userInfo']['itemId'] != '26278'>
								<div class="col-md-12">
									<div class="portlet light bordered">
										<div class="portlet-body"
											style="height: 13px; padding-top: 0px">
											<div style="float: left; width: 77%">
												<span>有色网报价：&nbsp;</span> <span
													style="font-family: 'Arial Negreta', 'Arial'; font-weight: 700; font-size: 13px; color: #333333;"
													id="itemName"></span> <span
													style="font-family: 'Arial Normal', 'Arial'; font-weight: 400; font-size: 13px; color: #333333;">
													￥</span> <span
													style="font-family: 'Arial Normal', 'Arial'; font-weight: 400; font-size: 14px; color: #D7000F;"
													id="price">00.00 </span> <span
													style="font-family: 'Arial Normal', 'Arial'; font-weight: 400; font-size: 13px; color: #333333;">元/吨&nbsp;
												</span>
																					<span style="font-family:'Arial Negreta', 'Arial';font-weight:700;font-size:13px;color:#333333;">1#锡</span>
																					<span style="font-family:'Arial Normal', 'Arial';font-weight:400;font-size:13px;color:#333333;"> ￥</span>
																					<span style="font-family:'Arial Normal', 'Arial';font-weight:400;font-size:14px;color:#D7000F;">12400.00 元/吨</span>
												<span
													style="font-family: 'Arial Normal', 'Arial'; font-weight: 400; font-size: 13px; color: #333333;">&nbsp;
													SHFE: </span> <span
													style="font-family: 'Arial Normal', 'Arial'; font-weight: 400; font-size: 14px; color: #D7000F;"
													id="avg">00.00</span> <span
													style="font-family: 'Arial Normal', 'Arial'; font-weight: 400; font-size: 14px; color: #333333;">&nbsp;
													涨速: </span> <span
													style="font-family: 'Arial Normal', 'Arial'; font-weight: 400; font-size: 14px; color: #D7000F;"
													id="float"> </span> <span style="display: none"
													id="remind1">&nbsp; 异动提醒&nbsp; </span> <span
													style="display: none" id="remind2"></span> <span
													style="font-family: 'Arial Normal', 'Arial'; font-weight: 400; font-size: 13px; color: #333333;">&nbsp;
													<a
													href="http://finance.sina.com.cn/futures/quotes/${productType}0.shtml"
													target='_blank'><i class="fa fa-bar-chart-o" onclick=""></i></a>
												</span>
											</div>
											<div
												style="float: right; width: 23%; text-align: right; padding-right: 18px;">
												<p>
													更新时间：<span id="updateTime"> </span>
												</p>
											</div>
										</div>
									</div>
								</div>
								</#if>
							</div>
						</div> -->
						<div class="col-md-12">
						<div class="portlet light bordered">
							<div class="portlet-body" style="height: 13px;padding-top: 0px">
								<div style="float: left;">
									视图： 
									<a href="javascript:queryView(0)">全部</a>|
									<a href="javascript:queryView(1)">我的报盘</a>|
									<a href="javascript:queryView(2)">部门创建的</a>|
									<a href="javascript:queryView(3)">回收站</a>
								</div>
								<input type="hidden" id="type" name="type">
							</div>
						</div>
					</div>
						<div class="portlet light bordered">
							<div style="float:left; padding-top: 7px;">
								<label for="recommend">推荐报盘价 ： </label>
							</div>
							<div style="width:200px; float:left; margin-left:15px;">
								<input type="text" id="recommend" value="${itemPrice.recommend!''}" class="form-control" />
							</div>
							<div style="float:left; margin-left:15px; padding-top: 7px;">
								<label for="high">最高报盘价 ： </label>
							</div>
							<div style="width:200px; float:left; margin-left:15px;">
								<input type="text" id="high"  value="${itemPrice.high!''}" class="form-control" />
							</div>
							<div style="float:left; margin-left:15px; padding-top: 7px;">
								<label for="low">最低还盘价 ：</label>
							</div>
							<div style="width:200px; float:left; margin-left:15px; margin-right:15px;">
								 <input type="text" id="low"  value="${itemPrice.low!''}" class="form-control" />
							</div>
							<button class="btn green" id="saveDealOfferPrice" >保存</button>
						</div>
						<input type="hidden" id="xuanzhong" name="xuanzhong">
						
						<div class="portlet light bordered">
							<div class="portlet-body">
								
								<div class="clearfix">
									<div style="width:100px; float:left;">
										<button class="btn green" id="del"    onclick="colsePool()">批量关闭</button>
									</div>
									<div style="width:110px; float:left;">
										<select class="form-control" id="attribute" onchange="fabuDate()">
											<option value="p2" selected>发布时间</option>
											<option value="p1">企业名称</option>
											<option value="p3">还盘企业</option>
											<option value="p4">还盘时间</option>
											<option value="p5">仓库</option>
											<option value="p6">采购类型</option>
										</select>
									</div>
									<div  style="width:110px; float:left; margin-left:15px;">
										<select class="form-control" id="operator">
											  <option value="1">包含</option>
									          <option value="2">不包含</option>
									          <option value="3">等于</option>
									          <option value="4">不等于</option>
									          <option value="5">开始字符</option>
									          <option value="6">结束字符</option>
									          <option value="7">为空</option>
									          <option value="8">不为空</option>
										</select>
									</div>
									<div style="width:200px; float:left; margin-left:15px;" id="contents">
										<input type="text"   class="form-control" id="content">
									</div>
									<input type="hidden" id="attributeHidden"/>
									<input type="hidden" id="operatorHidden"/>
									<input type="hidden" id="contentHidden"/>
									
										<button  onclick="queryByCondition()" class="btn green" style="margin-left:15px;">
											<i class="fa fa-search"></i> 搜索 
										</button>
									
										<button id="export" class="btn green" onclick="exportOffer();" style="float: right">导出</button>
										
										<button id="toorder" onclick="toOrder()" class="btn green" style="float: right ">撮合订单</button>
									
										<button id="addOffer" class="btn green" style="float: right">新建报盘</button>
									
								</div>
								<br />
								<!-- <h3>最新报盘</h3> -->
								<div class="dataDiv">
									<table id="grid" class="table table-striped table-bordered table-advance table-hover ttTbl">
										<tr>
											<td>
												<div class="loadingAjax">
												</div>
											</td>
										</tr>
									</table>
									<br />
								<!-- 
										<table width="667" class='ttTurnPageTbl'>
												<tr>
													<td id='perPageNum'></td>
													<td id="DataCount"></td>
													<td>
														<div style="width:150px;">
														<label onclick="prePage()" id="prePageBtn">上一页</label>&nbsp;&nbsp;
														<label onclick="nextPage()" id="nextPageBtn">下一页</label>
														</div>
													</td>
													<td id="CPofAP"></td>
													<td>转到：
														<select id="toPageNum" style="width:50px;"></select>页<input type="button" value="跳转" onClick="toPage()"></td>
												</tr>
										</table>
								 -->
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- 内容结束 -->
	<!-- 底部开始 -->
	<#include "/include/foot.html" />
	<!-- 底部结束 -->

	<!--[if lt IE 9]>
<script src="${request.getContextPath()}/Public/assets/global/plugins/respond.min.js"></script>
<script src="${request.getContextPath()}/Public/assets/global/plugins/excanvas.min.js"></script> 
<![endif]-->
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-migrate.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-ui/jquery-ui.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap/js/bootstrap.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery.blockui.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery.cokie.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/uniform/jquery.uniform.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/jquery-notific8/jquery.notific8.min.js"></script>

<script
	src="${request.getContextPath()}/Public/assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"
	type="text/javascript"></script>

<script
	src="${request.getContextPath()}/Public/assets/global/scripts/metronic.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/layout.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/global/plugins/kkpager.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/commonUtils.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/priceFloat.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/tc.min.js"
	type="text/javascript"></script>
<script
	src="${request.getContextPath()}/Public/assets/admin/scripts/ajaxfileupload.js"
	type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/js/business/businessTbl.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/js/business/companySel.js" type="text/javascript"></script>
<script src="${request.getContextPath()}/Public/js/layer/layer.min.js" type="text/javascript"></script>
<!-- select2控件 -->
<script type="text/javascript" src="${request.getContextPath()}/Public/assets/global/plugins/select2/select2.js"></script>
<script type="text/javascript" src="${request.getContextPath()}/Public/assets/global/plugins/select2/select2_locale_zh-CN.js"></script>
<link href="${request.getContextPath()}/Public/assets/global/plugins/select2/select2.css" rel="stylesheet" type="text/css">
<script>
	var actionUrl=BASE_URL+'/business/getBusinessInfo.do';
	var initTitleArr=['采购类型', '企业名称', '报盘价格', '仓库', '发布时间', '还盘数', '最新还盘价', '还盘企业', '最新还盘时间', '操作'];
	var initNameArr=['poolTypeText','fun_companyName', 'priceText', 'wareName', 'time_publishTime', 'counterNum', 'lastPriceText', 'lastCustomerName', 'time_lastTime'];
	$(function() {
		Metronic.init(); // init metronic core componets
		Layout.init(); // init layout
		CommonUtils.checkInit();
		PriceFloat.getPriceProduct();
		fabuDate();
		queryView();
		$("#addOffer").click(function(){
			document.location.href = BASE_URL + '/PoolManage/toaddPool.do';
		});
		
		//每天的交易指导价
		$("#saveDealOfferPrice").click(function(){
			
			var recommend = $("#recommend").val();
			var high = $("#high").val();
			var low = $("#low").val();
			if(!recommend){
				alert("推荐报盘价不能为空");
			} else if(!top){
				alert("最高报盘价不能为空");
			} else if(!low){
				alert("最低还盘价不能为空");
			}
			$.get("addItemPrice.do", {"recommend": recommend, "high" : high, "low":low }, function(data){
				if(data.status == 'ok'){
					alert(data.msg);
				} else {
					alert(data.msg);
				}
			});
			
		});
		
	});
	
	
	
	function exportOffer(){
		var attribute=$("#attribute").val();
		var operator=$("#operator").val();
		var content=$("#content").val();
		var urlParam="?attribute="+attribute+"&operator="+operator+"&content="+content;
		window.location = "${request.getContextPath()}/business/exportOffer.do"+ urlParam;
	}
	
	function  fabuDate (){
		var value=$("#attribute").val();
		//搜索条件改变，清空内容 
		$('#content').val("");
		if (value == 'p2'||value == 'p4') {
			$('#content').bind("click", function() {
				WdatePicker();
			});
		} else {
			$('#content').remove();
			$('#contents').append("<input type='text' class='form-control' id='content'>");
		}
	 }

	function toOrder(){
		var boxes = $("input[name='checkboxes']:checked");
		/* alert($(boxes[0]).attr("checked"));
		alert($(boxes[0]).attr("poolType")); */
		
		if(boxes.length != 2 && boxes.length != 1){
			//alert("撮合订单需要一个采购方和一个销售方！");
			alert("撮合订单至少需要一个报盘！");
			return ;
		}
		
		//新需求，2015年12月16日 上午11:26:55/zhangnan   选择一个卖盘/买盘,可以直接进入生成订单页面
		if(boxes.length == 1){
			//卖盘
			var poolType = $(boxes[0]).attr("poolType");
			var poolId = $(boxes[0]).attr("checkid");
			//alert(poolType+"-----"+poolId);
			if(poolType == 1){
				window.location = "${request.getContextPath()}/buypool/toaddsellorder.do?sid="+poolId+"&poolType="+poolType+"&flag="+9;
			}
			
			if(poolType == 2){
				window.location = "${request.getContextPath()}/buypool/toaddbuyorder.do?ids="+poolId+"&poolType="+poolType+"&flag="+9;
			}
			
		}
		if(boxes.length == 2){
			if(($(boxes[0]).attr("classValue").indexOf("sellPool")>=0&&$(boxes[1]).attr("classValue").indexOf("sellPool")>=0)||
					($(boxes[0]).attr("classValue").indexOf("buyPool")>=0&&$(boxes[1]).attr("classValue").indexOf("buyPool")>=0)){
				alert("撮合订单需要一个采购方和一个销售方！");
				return ; 
			}
			$.ajax({
				url : BASE_URL + "/business/checkOrderList.do",
				type : "post",
				dataType : 'JSON',
				data :{"poolId1" :$(boxes[0]).attr("checkid"),"poolType1":$(boxes[0]).attr("poolType"),"poolId2":$(boxes[1]).attr("checkid"),"poolType2":$(boxes[1]).attr("poolType"),},
				success : function(result) {
					/* if (result == "ERROR1") {
						$("#ERROR22").css("display","none");
						$("#ERROR33").css("display","none");
						$("#ERROR11").css("display","inline");
					}else if (result == "ERROR2") {
						$("#ERROR33").css("display","none");
						$("#ERROR11").css("display","none");
						$("#ERROR22").css("display","inline");
					}else if (result == "ERROR3") {
						$("#ERROR11").css("display","none");
						$("#ERROR22").css("display","none");
						$("#ERROR33").css("display","inline");
					}else{
						$("#ERROR11").css("display","none");
						$("#ERROR22").css("display","none");
						$("#ERROR33").css("display","none");
					} */
					
					if(result == "ERROR1"){
						alert("本客户已列为黑名单，不能进行还盘操作");
						return false;
					}else if(result == "ERROR2"){
						alert("卖方已被对方列为黑名单，不能进行还盘操作");
						return false;
					}else if(result == "ERROR3"){
						alert("双方互为黑名单关系，不能进行还盘操作");
						return false;
					}else{
						window.location = "${request.getContextPath()}/buyOrder/toOrder.do?value="+boxes[0].value+"$"+boxes[1].value;
					}
				}
			});
		}
	}
	
	function colsePool(){
		
		CommonUtils.doExecute('${request.getContextPath()}/business/closeOfferAll.do');
	}
	
</script>

</body>
</html>